#include <stddef.h>
#include <sys/time.h>

#include "YXTime.h"

#include <stdlib.h>
#include <time.h>

long long mstime() {
    struct timeval tv;
    long long      mst;

    gettimeofday(&tv, NULL);
    mst = ((long long) tv.tv_sec) * 1000;
    mst += tv.tv_usec / 1000;
    return mst;
}

char* yx_time_get_local_date_time() {
    time_t now;
    struct tm *timeinfo;
    char *buffer = (char *) malloc(20 * sizeof(char));

    // 获取当前时间
    time(&now);
    // 转换为当地时间
    timeinfo = localtime(&now);

    // 格式化日期和时间
    strftime(buffer, 20, "%Y-%m-%d %H:%M:%S", timeinfo);

    return buffer;
}
